home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / JForth / JTools / JARexx / tests / test_rxtools.f < prev    next >
Encoding:
FORTH Source  |  1992-01-24  |  1.3 KB  |  62 lines

  1. \ ARexx Test
  2. \
  3. \ This is an example of a minimal JForth program that
  4. \ sets up an ARexx port, receives messages, interprets
  5. \ them, then cleans up.
  6. \
  7. \ It uses the tools in the file jrx:ARexxTools.f
  8. \
  9. \ Send a string to this program using the ARexx command:
  10. \     address   'JFORTH'   'some Forth command'
  11. \
  12. \ Author: Phil Burk
  13. \ Copyright 1991 Phil Burk
  14.  
  15. getmodule includes
  16. getmodule arexxmod
  17.  
  18. include? CreatePort() ju:exec_support
  19. include? tolower ju:char-macros
  20. include? task-arexxTools.f jrx:ARexxTools.f
  21.  
  22. ANEW TASK-TEST_RXTOOLS.F
  23.  
  24. : TR.INTERPRET ( -- , wait.for a message then interpret it)
  25.     rx.wait.msg  >r
  26. \
  27. \ The first arg is an absolute pointer to a NULL terminated string.
  28.     0 r@ rx.arg[] @ if>rel 0count
  29.     cr ." Received: " 2dup type cr     \ for debugging
  30. \
  31. \ Interpret message as a Forth command line.
  32. \ In a cloned aplication you will need to use your own command set.
  33.     ( -- addr count ) $interpret
  34. \
  35. \ reply so ARexx can continue
  36.     r> rx.reply.msg
  37. ;
  38.  
  39. : TR.INTERP.LOOP ( -- )
  40.     >newline ." Waiting for messages from ARexx!" cr
  41.     rx-quit off
  42.     rx-data off
  43.     BEGIN
  44.         tr.interpret
  45.         rx-quit @
  46.         ?terminal or 
  47.     UNTIL
  48. ;
  49.  
  50. : TEST.AREXX  ( -- )
  51.     jforth_name rx.init 0=
  52.     IF
  53.         tr.interp.loop
  54.         rx.term
  55.     THEN
  56. ;
  57.  
  58. cr
  59. ." Enter in JForth: TEST.AREXX" cr
  60. ." Then enter in the CLI:   RX  TOJF" cr
  61. ." to run the ARexx program that controls JForth" cr
  62.